<template>
  <ListView :info="info"></ListView>
</template>
<script>
import ListView from '../../../../../components/common/ui/listView.vue'

export default {
  name: 'wellList',
  components: {
    ListView
  },
  data: function () {
    return {
      info: {
        title: '地磁',
        titleList: [],
        dataList: []
      }
    }
  },
  created: function () {
    this.initData()
    this.initTitleList()
  },
  methods: {
    initData: function () {
      let url = this.$base.getUrl('getList')
      let params = {
        url: url,
        data: {
          'deptId': this.$route.params.deptId,
          'moduleCode': '130'
        }
      }

      this.$store.dispatch('getForm', params).then((res) => {
        this.initDataList(res.list)
      })
    },
    initTitleList: function () {
      const arr = [{
        title: '设备', width: '50', key: 'equipmentName'
      }, {
        title: '状态', width: '50', key: 'equipmentStateName', colorSet: true
      }]
      this.info.titleList = arr
    },
    initDataList: function (list) {
      const arr = list
      arr.map(item => {
        const flag = item.equipmentState === '1'
        item.equipmentStateName = flag ? '畅通' : '阻塞'
        item.color = flag ? 'c-blue' : ''
      })
      this.info.dataList = arr
    }
  }
}
</script>
